package com.cq.xjms.model;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * 系实体类
 * @author caiqiang
 * @version 1
 */
@Entity
@Table(name="Department")
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
@NamedQueries( {
	@NamedQuery(name = "Department.list", query ="select i from Department i left join fetch i.institute order by i.id"),
	@NamedQuery(name = "Department.queryById", query ="select d from Department d left join fetch d.institute where d.institute.id=:id"),
	@NamedQuery(name = "Department.query", query ="select i from Department i where i.code=:code")
})
public class Department extends BaseEntity
{
	
	public static final String DEPARTMENT_LIST = "Department.list";
	public static final String DEPARTMENT_QUERY = "Department.query";
	public static final String DEPARTMENT_QUERYById = "Department.queryById";
	private static final long serialVersionUID = 1539350453366775796L;
	
	@Column(name = "NAME",length=20,nullable = false)
	private String name;
	
	@Column(name ="CODE" ,length=10)
	private String code ;
	
	@ManyToOne(fetch = FetchType.LAZY)
	private Institute institute;
	
	@OneToMany(fetch = FetchType.LAZY,mappedBy="department")
	private List<Clazz> claes;

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public Institute getInstitute() {
		return institute;
	}

	public void setInstitute(Institute institute) {
		this.institute = institute;
	}

	public List<Clazz> getClaes() {
		return claes;
	}

	public void setClaes(List<Clazz> claes) {
		this.claes = claes;
	}
	
	

}
